<template>
  <div style="display: inline;">
    <el-button type="success" icon="el-icon-plus" @click="clickAddParameter()" size="medium">添加</el-button>

    <el-dialog title="添加参数" :visible.sync="dialogVisible" :append-to-body="true" :close-on-click-modal="false" class="my-dialog-no-bg" width="600px">
      <el-form>
        <el-form-item label="参数名:" :label-width="formLabelWidth" required>
          <el-input placeholder="请输入参数名" v-model="parameterForm.name"></el-input>
        </el-form-item>

        <el-form-item label="参数类型:" :label-width="formLabelWidth" required>
          <el-select placeholder="请选择" style="width:100%" v-model="parameterForm.type">
            <el-option label="constant" value="constant"></el-option>
            <el-option label="sql" value="sql"></el-option>
            <el-option label="interface" value="interface"></el-option>
            <el-option label="reflect" value="reflect"></el-option>
            <el-option label="case" value="case"></el-option>
            <el-option label="wait" value="wait"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="参数值:" :label-width="formLabelWidth" required>
          <el-input placeholder="请输入参数值" v-model="parameterForm.value"></el-input>
        </el-form-item>
        <el-form-item label="添加人员:" :label-width="formLabelWidth" required>
          <el-input placeholder="请输入人员" v-model="parameterForm.author"></el-input>
        </el-form-item>
        <el-form-item label="是否全局:" :label-width="formLabelWidth" required>
          <el-select placeholder="请选择" style="width:100%" v-model="parameterForm.global">
            <el-option label="是" value="1"></el-option>
            <el-option label="否" value="0"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="描述:" :label-width="formLabelWidth" required>
          <el-input type="textarea" :rows="3" placeholder="请输入描述" v-model="parameterForm.message"></el-input>
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false" size="medium">取 消</el-button>
        <el-button type="primary" @click="addOrEditParameter(type,parameterForm)" size="medium">确 定</el-button>
      </div>
    </el-dialog>
  </div>

</template>


<script>
import { addEnv, getEnv, deleteEnv, updateEnv } from '@/api/env'
import { getProject } from '@/api/project'
export default {

  data () {
    return {
      dialogVisible: false,
      projectId: this.$store.state.projectId,

      formLabelWidth: "100px",
      type: "add",
      ProjectList: {
        list: []
      },


      parameterForm: {
        type: 'constant',
        author: 'asen',
        envId: '1',
        projectId: this.$store.getters.projectId,
      },

    }
  },

  methods: {

    //点击添加按钮
    clickAddParameter () {

    },

    //添加或更新环境
    addOrEditParameter (type, data) {

    }
  },

  mounted () {
    this.parameterForm.projectId = this.$store.state.projectId
  }



}
</script>

<style scoped>
</style>
